<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加管理员</title>
<script type="text/javascript" src="../js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/npm.js"></script>
<link rel="stylesheet" href="../css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="../css/bootstrap.css" />
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/bootstrap-theme.css" />
<style type="text/css">
.forms {
	margin: 20px auto;
	width: 50%;
	border: 1px solid;
	border-color: #F0F0F0;
	border-radius: 0.3em;
	text-align: center;
}

.sub {
	
}

.mm {
	text-align: right;
}

.check {
	color: red;
	font-weight: lighter;
	width: 200px;
	text-align: left;
}
</style>
<script type="text/javascript">
	function check(id) {
		if (id == 'name') {
			/* 手机验证 */
			var value = $("#" + id).val();
			var label = $("#" + id + "Label");
			label.text("");
			if (value == "") {

				label.text("*角色不能为空!");
			} else if (value.length > 8) {
				label.text("*角色长度不能多于8位!");
			} else if (value.length < 2) {
				label.text("*角色长度不能少于2位!");
			}
		} else if (id == 'phone') {
			/* 手机验证 */
			var value = $("#" + id).val();
			var label = $("#" + id + "Label");
			label.text("");
			if (!/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/
					.test(value)) {

				label.text("*手机格式不正确!");
			}
		} else if (id == 'password') {
			/* 密码验证 */
			var value = $("#" + id).val();
			var label = $("#" + id + "Label");
			label.text("");
			if (!/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value)) {

				label.text("*密码必须为英文加数字!");
			}
		} else if (id == 'surepassword') {
			/* 密码验证 */
			var value = $("#" + id).val();
			var label = $("#" + id + "Label");
			var password = $("#password").val();
			label.text("");
			if (value != password) {

				label.text("*确认密码错误");
			}
		}
	}
	function regForm() {
		var accont = $("#accont").val();
		var uname = $("#name").val();
		var phone = $("#phone").val();
		var password = $("#password").val();
		var pwd = $("#surepassword").val();
		if (accont == "") {
			var label = $("#acLabel");
			label.text("*账号不能为空！");
			return false;
		}
		if (phone == "") {
			var label = $("#phoneLabel");
			label.text("*手机号码不能为空！");
			return false;
		}
		if (name == "") {
			var label = $("#unameLabel");
			label.text("*昵称不能为空！");
			return false;
		}
		if (password == "") {
			var label = $("#pwdLabel");
			label.text("*密码不能为空！");
			return false;
		}
		if (pwd == "") {
			var label = $("#pwdLabel");
			label.text("*确密码不能为空！");
			return false;
		}
	}
</script>
</head>
<body>


	<form class="forms" role="form" action="managepeople?action=add"
		method="post" onsubmit="return regForm()">
		<h3 style="text-align: center;">添加管理员</h3>
		<table class="table table-striped table-hover table-bordered">
			<tr class="info">
				<td class="mm">账号：</td>
				<td><input type="text" class="form-control" id="accont"
					name="accont" placeholder="请输入账号" onfocusout="check('accont')"></td>
				<td class="check"><label id="acLabel">*必填</label></td>
			</tr>
			<tr class="info">
				<td class="mm">角色：</td>
				<td><input type="text" class="form-control" id="name"
					name="name" placeholder="请输入角色名称" onfocusout="check('name')"></td>

				<td class="check"><label id="nameLabel"></label></td>
			</tr>
			<tr class="info">
				<td class="mm">电话：</td>
				<td><input type="text" class="form-control" id="phone"
					name="phone" placeholder="请输入电话" onfocusout="check('phone')"></td>
				<td class="check"><label id="phoneLabel"></label></td>
			</tr>
			<tr class="info">
				<td class="mm">密码：</td>
				<td><input type="password" class="form-control" id="password"
					name="password" placeholder="请输入密码" onfocusout="check('password')"></td>
				<td class="check"><label id="pwdLabel"></label></td>
			</tr>
			<tr class="info">
				<td class="mm">确认密码：</td>
				<td><input type="password" class="form-control"
					id="surepassword" name="surepassword" placeholder="确认密码"
					onfocusout="check('surepassword')"></td>
				<td class="check"><label id="surepwdLabel"></label></td>
			</tr>
			<tr class="info">
				<td class="sub" colspan="3"><button type="submit"
						class="btn btn-default btn-info">+添加</button></td>
			</tr>
		</table>

	</form>
</body>
</html>